//
//  Pizza.m
//  Charles
//
//  Created by Charles on 2017/6/15.
//  Copyright © 2017年 charles. All rights reserved.
//

#import "Pizza.h"
#import "Factory.h"

#pragma mark - 原料

@implementation ThickCrustDough

- (NSString *)toString {
    return @"ThickCrustDough";
}

@end

@implementation ThinCrustDough

- (NSString *)toString {
    return @"ThinCrustDough";
}

@end

@implementation PlumTomatoSauce

- (NSString *)toString {
    return @"PlumTomatoSauce";
}

@end

@implementation MarinaraSauce

- (NSString *)toString {
    return @"MarinaraSauce";
}

@end

@implementation MozzarellaCheese

- (NSString *)toString {
    return @"MozzarellaCheese";
}

@end

@implementation ReggianoCheese

- (NSString *)toString {
    return @"ReggianoCheese";
}

@end

@implementation FrozenClams

- (NSString *)toString {
    return @"FrozenClams";
}

@end

@implementation FreshClams

- (NSString *)toString {
    return @"FreshClams";
}

@end


#pragma mark - 比萨

@implementation Pizza
- (instancetype)init {
    if (self = [super init]) {
        self.toppings = [[NSMutableArray alloc]initWithCapacity:0];
    }
    return self;
}
- (void)prepare {
    NSLog(@"Preparing %@",self.name);
    NSLog(@"Tossing dough...");
    NSLog(@"Adding sauce...");
    NSLog(@"Adding topping:");
    for (int i = 0; i<self.toppings.count; i++ ) {
        NSLog(@" %@",self.toppings[i]);
    }
}

- (void)bake {
    NSLog(@"Bake for 25 minutes at 350");
}

- (void)cut {
    NSLog(@"Cutting the pizza into diagonal slices");
}

- (void)box {
    NSLog(@"Place pizza in official pizzaStore box");
}

@end

@implementation CLPizza

- (void)prepare {
    
}

- (void)bake {
    NSLog(@"Bake for 25 minutes at 350");
}

- (void)cut {
    NSLog(@"Cutting the pizza into diagonal slices");
}

- (void)box {
    NSLog(@"Place pizza in official pizzaStore box");
}

- (NSString *)toSring {
    NSLog(@"打印比萨！！");
    return nil;
}

@end

@interface CheesePizza ()

@property (strong,nonatomic) id<PizzaIngredientFactory> ingredientFactory;

@end

@implementation CheesePizza

- (instancetype)initWithFactory:(id<PizzaIngredientFactory>)factory {
    if (self = [super init]) {
        self.name = @"CheesePizza";
        self.ingredientFactory = factory;
    }
    return self;
}

- (void)prepare {
    NSLog(@"Preparing %@",self.name);
    self.dough = [self.ingredientFactory createDugh];
    self.sauce = [self.ingredientFactory createSauce];
    self.cheese = [self.ingredientFactory createCheese];
}

@end

@implementation NYCheesePizza

- (instancetype)init {
    if (self = [super init]) {
        self.name = @"NYCheesePizza";
        self.dough = @"Thin Crust Dough";
        self.sauce = @"Marinara Sauce";
        [self.toppings addObject:@"Grated Reggiano Cheese"];
    }
    return self;
}

@end

@implementation NYPepperoniPizza

- (instancetype)init {
    if (self = [super init]) {
        self.name = @"NYPepperoniPizza";
        self.dough = @"Thin Crust Dough";
        self.sauce = @"Marinara Sauce";
        [self.toppings addObject:@"Grated Reggiano Cheese"];
    }
    return self;
}
@end

@implementation NYClamPizza

- (instancetype)init {
    if (self = [super init]) {
        self.name = @"NYClamPizza";
        self.dough = @"Thin Crust Dough";
        self.sauce = @"Marinara Sauce";
        [self.toppings addObject:@"Grated Reggiano Cheese"];
    }
    return self;
}
@end

@implementation NYVeggiePizza

- (instancetype)init {
    if (self = [super init]) {
        self.name = @"NYVeggiePizza";
        self.dough = @"Thin Crust Dough";
        self.sauce = @"Marinara Sauce";
        [self.toppings addObject:@"Grated Reggiano Cheese"];
    }
    return self;
}
@end
